package v1

import (
	"github.com/gin-gonic/gin"
	"guns-go/model/request"
	"guns-go/model/response"
	"guns-go/service"
)

// @Tags Notice
// @Summary 公告列表
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data body request.SysNoticeParam true "请求参数"
// @Success 200 {string} string "{"success":true,"data":{},"message":"请求成功","code":200}"
// @Router /sysNotice/page [get]
func SysNoticePage(c *gin.Context) {

	var N request.SysNoticeParam
	_ = c.ShouldBindQuery(&N)

	err, sysNoticePageResult := service.SysNoticePage(&N, c)

	if err != nil {
		response.FailWithMessage(err.Error(), c)
		return
	}
	response.OkWithData(sysNoticePageResult, c)
}

// @Tags Notice
// @Summary 新增公告
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data body request.SysNoticeParam true "请求参数"
// @Success 200 {string} string "{"success":true,"data":{},"message":"请求成功","code":200}"
// @Router /sysNotice/add [post]
func SysNoticeAdd(c *gin.Context) {

	var N request.SysNoticeParam
	_ = c.ShouldBindJSON(&N)

	err := service.SysNoticeAdd(&N, c)

	if err != nil {
		response.FailWithMessage(err.Error(), c)
		return
	}
	response.Ok(c)
}

// @Tags Notice
// @Summary 修改公告
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data body request.SysNoticeParam true "请求参数"
// @Success 200 {string} string "{"success":true,"data":{},"message":"请求成功","code":200}"
// @Router /sysNotice/edit [post]
func SysNoticeEdit(c *gin.Context) {

	var N request.SysNoticeParam
	_ = c.ShouldBindJSON(&N)

	err := service.SysNoticeEdit(&N)

	if err != nil {
		response.FailWithMessage(err.Error(), c)
		return
	}
	response.Ok(c)
}

// @Tags Notice
// @Summary 公告详情
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data body request.SysNoticeParam true "请求参数"
// @Success 200 {string} string "{"success":true,"data":{},"message":"请求成功","code":200}"
// @Router /sysNotice/detail [get]
func SysNoticeDetail(c *gin.Context) {

	var N request.SysNoticeParam
	_ = c.ShouldBindQuery(&N)

	err, sysNoticeDetailResult := service.SysNoticeDetail(&N, c)

	if err != nil {
		response.FailWithMessage(err.Error(), c)
		return
	}
	response.OkWithData(sysNoticeDetailResult, c)
}

// @Tags Notice
// @Summary 删除公告
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data body request.SysNoticeParam true "请求参数"
// @Success 200 {string} string "{"success":true,"data":{},"message":"请求成功","code":200}"
// @Router /sysNotice/delete [post]
func SysNoticeDelete(c *gin.Context) {

	var N request.SysNoticeParam
	_ = c.ShouldBindJSON(&N)

	err := service.SysNoticeDelete(&N)

	if err != nil {
		response.FailWithMessage(err.Error(), c)
		return
	}
	response.Ok(c)
}

// @Tags Notice
// @Summary 修改公告状态
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data body request.SysNoticeParam true "请求参数"
// @Success 200 {string} string "{"success":true,"data":{},"message":"请求成功","code":200}"
// @Router /sysNotice/changeStatus [post]
func SysNoticeChangeStatus(c *gin.Context) {

	var N request.SysNoticeParam
	_ = c.ShouldBindJSON(&N)

	err := service.SysNoticeChangeStatus(&N)

	if err != nil {
		response.FailWithMessage(err.Error(), c)
		return
	}
	response.Ok(c)
}

// @Tags Notice
// @Summary 公告接受者分页查询
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data body request.SysNoticeParam true "请求参数"
// @Success 200 {string} string "{"success":true,"data":{},"message":"请求成功","code":200}"
// @Router /sysNotice/received [get]
func SysNoticeReceived(c *gin.Context) {

	var N request.SysNoticeParam
	_ = c.ShouldBindQuery(&N)

	err, sysNoticeReceivedPage := service.SysNoticeReceived(&N, c)

	if err != nil {
		response.FailWithMessage(err.Error(), c)
		return
	}
	response.OkWithData(sysNoticeReceivedPage, c)
}
